/*
 * @Author: Xavier 1305433186@qq.com
 * @Date: 2024-07-27 16:15:43
 * @LastEditors: Xavier 1305433186@qq.com
 * @LastEditTime: 2024-08-16 17:02:54
 * @FilePath: \JS32T031_SDK\User\board.c
 * @Description:
 *
 * STAYTRUE (c) 2024 by ${Xavier}, All Rights Reserved.
 */

#include "include.h"
#include "board.h"
void timer_1_init(void)
{
    NVIC_InitTypeDef nvic; // 使能TIMER0中断
    nvic.NVIC_IRQChannel = TIM1_IRQn;
    nvic.NVIC_IRQChannelPriority = 0;
    nvic.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvic);

    TYPE_LL_TIMER_INIT timer_init;

    timer_init.prescaler = LL_TIMER_PSC_128;            // 不分频
    timer_init.timer_src_sel = LL_TIMER_SRC_SYS_RISING; // 选择系统时钟
    ll_timer_init(TIMER1, &timer_init);

    TYPE_LL_TIMER_CNT_CFG cnt_cfg;
    cnt_cfg.count_initial = 0;
    cnt_cfg.count_period = 37500; // 100ms   48Mhz*100000us/128 = 37,500
    cnt_cfg.count_ie = ENABLE;
    ll_timer_cnt_mode_config(TIMER1, &cnt_cfg);
    ll_timer_start(TIMER1, LL_TIMER_MODE_SEL_COUNTER);
}
/* 任务时钟初始化 */
void task_clock_init(void)
{
    timer_1_init();
}

void board_init(void)
{
    eflash_init();
    driver_board_uart_init(); // 驱动板 串口初始化
    buzzer_init();
    wireless_433_Config(); // 433 遥控初始化
    led_io_init();
    led_display_init();

    beep_start();
    delay_ms_software(100);
    beep_check_stop();
}
